package com.ouyu.pdfprint.print_pdf.config;

import com.ouyu.pdfprint.print_pdf.JavaToPdfHtmlFreeMarker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <pre>
 * @Auther: ousakai
 * @Date: 2020-06-04 15:53
 * @Description:
 * 修改版本: 1.0
 * 修改日期:
 * 修改人 :
 * 修改说明: 初步完成
 * 复审人 :
 * </pre>
 */
@Configuration
@EnableConfigurationProperties(PdfProperties.class)
@ConditionalOnProperty(value = "print.pdf.enable",havingValue = "true")
public class PdfAutoConfiguration {

    private final PdfProperties pdfProperties;

    public PdfAutoConfiguration(PdfProperties pdfProperties) {
        this.pdfProperties =pdfProperties;
    }

    @Bean
    public JavaToPdfHtmlFreeMarker autoConfiguration(){
       return  new JavaToPdfHtmlFreeMarker(pdfProperties);
    }
}
